/*
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-10-10 19:07:59
 * @LastEditTime: 2020-04-25 11:42:40
 * @LastEditors: lijing
 */
import axios from "../../request/http"
import urls from "../../request/url"
const app = {
  state: {
    commToken: window.localStorage.getItem("comm_token"),
    adminToken: window.sessionStorage.getItem("admin_token"),
    blogInfo: {},
  },
  mutations: {
    setCommToken(state, token) {
      state.commToken = token;
      if (token) {
        window.localStorage.setItem("comm_token", token);
      } else {
        window.localStorage.removeItem("comm_token");
      }
    },
    setAdminToken(state, token) {
      state.adminToken = token;
      if (token) {
        window.sessionStorage.setItem("admin_token", token);
      } else {
        window.sessionStorage.removeItem("admin_token");
      }
    },
    setBlogInfo(state, info) {
      state.blogInfo = info;
    }
  },
  actions: {
    getBlogInfo(context) {
      axios.get(urls.comm.blogInfo).then(res => {
        context.commit('setBlogInfo', res.data);
      });
    }
  }
}
export default app;